package com.ymatou.iapi.productquery.service;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONObject;

import com.google.gson.reflect.TypeToken;
import com.ymatou.iapi.livebuyer.parameter.LiveRoomInfo;
import com.ymatou.iapi.productquery.compare.ProductQueryInterface;
import com.ymatou.iapi.productquery.parameter.ProductInListDto;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.business.YmatouAutoTestCall;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.MapUtil;

public class GetNewestProductListBySellerIdCall extends YmatouAutoTestCall  implements ProductQueryInterface{
	private static String opurl="api/Product/GetNewestProductListBySellerId";
	
	public GetNewestProductListBySellerIdCall(){
		super(EnvSetup.getSystemUrl("productquery"), opurl, "GET", "PARAM");
	}
	
	
	@Override
	public void addDefHeader(){
	}
	
	public JSONObject callAndGetReturnData(String sellerId){
		return callAndGetReturnData(MapUtil.hashMap("SellerId",sellerId,"pageSize",500000,"curPage",1));
	}
	
	@Override
	public JSONObject search(List<String> list) {
		return callAndGetReturnData(list.get(0));
	}
	
	public static void main(String[] args) {
		new GetNewestProductListBySellerIdCall().callAndGetReturnData("3383");
	}

	public ArrayList<ProductInListDto> getProductList()
    {
		ArrayList<ProductInListDto> data = null;
        try {
        	String ProductList=getJsonObject().get("Data").getAsJsonObject().get("ProductList").getAsJsonArray().toString();
        	data=(ArrayList<ProductInListDto>) FormatUtil.GSONToObject(ProductList, new TypeToken<ArrayList<ProductInListDto>>() {}.getType());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return data;
    }
	
}
